*
* LAB1 PROGRAM: Go in loop 10 times and write value of A to DPTR. if Value greater tahn 50h jump to exit label
*
		ORG	$0000			START AT 0000H
START	XRL A,A				RESET A TO 00H
		MOV R1,A			R1 HOLDS COUNT FOR NUMBER OF LOOPS - 00H		
		MOV R5,#0Ah			SET COUNT TO 0AH IN R5
		MOV DPTR,#0100H		SET DPTR TO 0100H	

LOOP	CLR C				CLEAR CARRY FLAG
		MOV R4,A			BACKUP A
		SUBB A,#51h			IF A IS GREATER THAN 51 CARRY IS NOT SET HALT PROGRAM
		JNC END			    JUMP IF A IS GREATER THAN 51H
		MOV A,R4			RESTORE A

		MOVX [DPTR],A		STORE A IN EXT MEM
		INC A				INCREMENT A
		INC R1				INCREMENT COUNTER
		INC DPTR			INCREMENT DPTR
		DJNZ R5,LOOP		DECREMENT COUNTER AND REPEAT IF R5 IS NON ZERO

END	    MOV R0,#20h			SET LOCATION TO INTERNAL RAM LOCATION 20H
		MOV A,R1			GET COUNTER TO A TO MOVE TO MEMORY
		MOV [R0],A			STORE A AT MEMORY LOCATION POINTED TO BY R0
		DB $A5				STOP